<template>
	<view class="wrap">
		<u-form class="form" :model="model" :rules="rules" ref="uForm" label-position="top">
			<u-form-item label="谈话内容是否属实" prop="rateTalkIsReal" label-width="120">
				<js-radio v-model="model.rateTalkIsReal" :items="yesNoOption" itemLabel="dictValue" itemValue="dictKey" ></js-radio>
			</u-form-item>
			<u-form-item label="对本次谈话的建议" prop="rateContent" label-width="120">
				<u-input type="textarea" placeholder="请输入评价" v-model="model.rateContent" :border="true" height="200" maxlength="500" />
			</u-form-item>
		</u-form>
		<view style="display: flex;flex-direction: row;">
			<u-button class="btn" style="width: 50%;margin-right: 10rpx;" type="primary" @click="submit">保存</u-button>
			<u-button class="btn" style="width: 50%;" @click="cancel">取消</u-button>
		</view>
	</view>
</template>
<script>
/**
 * Copyright (c) 2013-Now http://aidex.vip All rights reserved.
 */
export default {
	data() {
		return {
			model: {
				talkId: '',
				rateType: null,
				rateContent: '',
				rateScore: null,
			},
			yesNoOption:[],
			rules: {
				rateScore: [
					{
						validator: (rule, value, callback) => {
							return value>0;
						},
						message: '请填写星级评价！'
					}
				],
			},
		};
	},
	onLoad(params){
		this.model.talkId=params.talkId;
		this.$u.api.dictData({code: 'yes_no'}).then(res => {
			if (typeof res === 'object' && res.result === 'login'){
				return;
			}
			this.yesNoOption = res.data;
		});
	},
	onReady() {
		this.$refs.uForm.setRules(this.rules);
	},
	methods: {
		submit() {
			this.$refs.uForm.validate(valid => {
				if (valid) {
					uni.showLoading({
						title: '提交中....'
					})
					this.$u.api.mis.misAssistantTalk.submitRate(this.model).then(res => {
						uni.hideLoading();
						uni.showModal({
							title: '提示',
							content: res.msg,
							showCancel: false,
							success: function () {
								if (res.code == 200) {
									uni.navigateTo({url: 'index'});
								}
							}
						});
					});
				} else {
					this.$u.toast('请填写必填项。');
				}
			});
		},
		cancel() {
			uni.navigateTo({url: 'index'});
		},
	}
};
</script>
<style lang="scss" scoped>

</style>
